Skip to content

feat(relay): plan-based gating, KV error logging, and request logging#33

Open
iceteaSA wants to merge 3 commits into
cortexkit:mainfrom
iceteaSA:feat/relay-worker-improvements
Open

feat(relay): plan-based gating, KV error logging, and request logging#33
iceteaSA wants to merge 3 commits into
cortexkit:mainfrom
iceteaSA:feat/relay-worker-improvements

Conversation

@iceteaSA

@iceteaSA iceteaSA commented May 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Relay Worker improvements + a CLI deploy fix so the worker's plan gating actually works.

Worker (relay.ts WORKER_SCRIPT)

  • Plan-based gating via the RELAY_PLAN env binding: paid enables WebSocket transport + structured logging; otherwise the worker stays HTTP-only (WS upgrades return 403) to fit the free-tier CPU budget.
  • KV error logging with a 7-day TTL.
  • Request logging (paid plan only).

CLI deploy (cli.ts)

  • relaySetup now selects the plan — RELAY_PLAN/CLOUDFLARE_PLAN env, else prompt (default free, the safe option for any account) — and passes it through.
  • uploadRelayWorker sets the RELAY_PLAN binding on every deploy. A worker PUT replaces all bindings, so without this the worker silently reverted to free-plan behaviour on redeploy.
  • Relay transport now matches the plan (websocket for paid, http for free).

Tests

  • cli.test.ts asserts the relay-setup deploy carries the RELAY_PLAN binding and selects the matching transport.
  • relay-worker-miniflare.test.ts covers the gated worker behaviour.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 2 files

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread packages/core/src/relay.ts
@iceteaSA iceteaSA force-pushed the feat/relay-worker-improvements branch from 5e33a83 to 693b3db Compare May 22, 2026 17:08
@iceteaSA iceteaSA force-pushed the feat/relay-worker-improvements branch 5 times, most recently from f381ba8 to 373871d Compare June 3, 2026 18:17
Comment thread packages/core/src/relay.ts Outdated
Comment thread packages/opencode/src/tests/relay-worker-miniflare.test.ts Outdated
Comment thread packages/core/src/relay.ts Outdated
@iceteaSA iceteaSA force-pushed the feat/relay-worker-improvements branch 4 times, most recently from e3cc138 to 2e7467c Compare June 4, 2026 07:56

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iceteaSA has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iceteaSA has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@iceteaSA iceteaSA force-pushed the feat/relay-worker-improvements branch from b4939fe to dec18d3 Compare June 5, 2026 16:43

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iceteaSA has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@iceteaSA iceteaSA force-pushed the feat/relay-worker-improvements branch from dec18d3 to 6a5b8e6 Compare June 9, 2026 12:15

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iceteaSA has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@iceteaSA iceteaSA force-pushed the feat/relay-worker-improvements branch from 6a5b8e6 to 0f978d5 Compare June 10, 2026 09:45

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iceteaSA has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@iceteaSA iceteaSA force-pushed the feat/relay-worker-improvements branch from 0f978d5 to 0105cae Compare June 10, 2026 10:44

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iceteaSA has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.

iceteaSA added 3 commits June 10, 2026 13:26
…ging

Worker script improvements:
- Plan-based gating: WebSocket transport requires paid plan (RELAY_PLAN=paid)
- KV error logging: non-429/403 upstream errors logged to KV with 7-day TTL
- Request logging: HTTP and WebSocket requests logged on paid plan
- GET health endpoint returns plan info and available transports
…ort to plan

The worker gates websocket + logging on RELAY_PLAN, but the CLI never set it,
so a worker PUT silently reverted to free-plan behaviour. relaySetup now selects
the plan (env or prompt, default free) and passes it through uploadRelayWorker as
the RELAY_PLAN binding; transport defaults to websocket for paid, http for free.
@iceteaSA iceteaSA force-pushed the feat/relay-worker-improvements branch from 0105cae to 7823761 Compare June 10, 2026 11:28

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iceteaSA has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant